Recap:

Inheritance

* Parent class -is a--> child class
* protected reserved word
* super allows the child class to call the constructor of the parent class
super(); // This would call the 0-parameter constructor of the parent class
* Method overriding: process of redefining an inherited method
super would make it possible in this case to call the original version of the method
* Abstract classes: a class with 0 or more abstract methods

If the class has 1 or more abstract methods ==> Class will have to be abstract

Plane -- Vehicle -- Car
	  |
	  |
	Boat

Since all vehicles have a speed, then it would make sense to declare the speed variable inside
the body of the Vehicle class. 
Not all vehicles have wheel. In this case, we create the nbOfWheels variable only inside the 
classes for which that variable is appropriate
fuelConsumption would be declared as an abstract method inside the Vehicle class; However, 
we leave it up to the descendant classes to provide their own implementations of the method

- Application#1: 
RollingDice.java
Die.java

public class Die extends Object

Object's version of toString: prints the name of class + @ + hash value
Object's version of equals: checks the compared objects are aliases

- Java does not support multiple inheritance: 

In Java, a child class cannot be derived from multiple parent classes. 

Through interfaces, we can create multiple is-a relationships. 

-------------------------------------------------------------------------------------

Application#2: LeetCode 724
 0	1	2	3	4
[1	2	3	0	3]

Two solutions: Solution#1: quadratic (O(n^2)); through preprocessing ===> linear solution#2: O(n)

- Find the second smallest value

[1	4	3	2]

- Application#3: Misc.java

- Last topic: 
In Java, parameters are passed by value
Application#4: SwappingValues.java

main

int val1: 2 and val2: 3

swap(2, 3)

swap:
int val1: 3 and val2: 2


main:

val1 ---> 2 <--- val1 and val2 ---> 3 <--- val2

swap

int[] arr = {1, 2, 3};
System.out.println(arr); // Address of the first value

---------------------The End-----------------------------------

Andrei Karpathy
"You can delegate thinking to an LLM, but you cannot delegate understanding to an LLM"

"Never give up on your childhood dreams"



























